<?
	list($langString) = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
	//FIXME: check if exists
	$langSource = file_get_contents("resources/lang/".$langString.".js");
	preg_match_all("/lang\.([a-zA-Z0-9]*) = \"([a-zA-Z0-9 \.:]*)\"/",$langSource,$arr);
	$langWord = array("/%langString%/");$langPhrase = array($langString);
	foreach($arr[0] as $k=>$v){$langWord[] = "/%".$arr[1][$k]."%/";$langPhrase[] = $arr[2][$k];}

	$content = file_get_contents("resources/templates/index.html");
	header("Content-type: text/html");

	$content = preg_replace($langWord,$langPhrase,$content);
	echo $content;
?>
